package com.lawalong.redbubblemicroservice.model;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

import javax.xml.bind.annotation.XmlRootElement;

@Component("treasure")
@PropertySource("classpath:treasure.properties")
@XmlRootElement
public class Treasure {
    String name;
    String category;
    double price;

    public Treasure() {
        // TODO Auto-generated constructor stub
    }

    @Autowired
    public Treasure(Environment env){
        System.out.println("Server bean Creation...");
        setName(env.getProperty("name"));
        setCategory(env.getProperty("category"));
        setPrice(Double.parseDouble(env.getProperty("price")));
        System.out.println(this.toString());
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }
    @Override
    public String toString() {
        // TODO Auto-generated method stub
        return name+"|"+category+"|"+price;    }
}
